import React,{useState} from 'react'
import './SelectItem.less'
interface IProps{
  title:string,
  data:Idata[],
  getval:(p:string|number)=>void

}
interface Idata{
  key:string,
  value:string|number
}
export default function SelectItem({title,data,getval}:IProps) {
  let [value,setValue] = useState(0)
  return (
    <div className='selectitem'>
      <div className='title' onClick={()=>{console.log(data)}}>{title}</div>
      <ul>
          {
            data.map((item,index)=>{
              return (<li key={index} className={index===value?"active":""} onClick={()=>{
                setValue(index)
                getval(item.value)
              }}>{item.key}</li>)
            })
          }
      </ul>
    </div>
  )
}
